<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * create parts of the menu for static-pages
 * used from core.php
 * use staticpage.menu.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
function topmenuEntry($refPage, $activePagename)
{
	db::getInstance()->orderBy('page_order', 'ASC');
	db::getInstance()->where('groupname', 'staticmenu');
	db::getInstance()->where('page_active', 1);
	$cols = Array('page_header', 'page_name');
	$top = db::getInstance()->get("page", null, $cols);

	$pages = array();

	foreach ($top as $topEntry)
	{
		if ($topEntry['page_name'] == 'page-startpage')
		{
			$pages[] = array(
			 'pageLink' => '<a href="/index.php?name=' . $topEntry['page_header'] . 
			 '" class="mainlevel-nav-link">' .
			 $topEntry['page_header'] . '</a>');
		}
		elseif ($topEntry['page_name'] == $activePagename)
		{
			$pages[] = array(
			 'pageLink' => '<a href="/index.php?page=page&title=' . $topEntry['page_name'] .
			 '&name=' . $topEntry['page_header'] . '" class="mainlevel-nav-active">' .
			 $topEntry['page_header'] . '</a>');
		}
		else
		{
			$pages[] = array(
			 'pageLink' => '<a href="/index.php?page=page&title=' . $topEntry['page_name'] .
			 '&name=' . $topEntry['page_header'] . '" class="mainlevel-nav-link">' .
			 $topEntry['page_header'] . '</a>');
		}
		//id="active_menu-nav"
	}
	$refPage->assign('pages', $pages);
}

//<a href="{pageLink}" class="mainlevel-nav">{pagetitel}</a>
?>